<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <title>添加商品</title>
    <style type="text/css">
        .checkbox{
             margin-left:5px;
             width:90px;
             margin-top: 10px;
        }
        textarea{
            width: 300px;
            height: 100px;
        }


        /*tab切换*/
 ul.tab{
  width:100%;
  height: 40px;
  border: 1px solid #E5E5E5;
}
 ul.tab li{
float: left;
background: #FAFAFA;
width:111px;
height: 40px;
line-height: 40px;
text-align: center;
border-right: 1px solid #E1E1E1;
}
 ul.tab li a{
  font-size: 14px;
  color:#333;
}
 ul.tab li a span{
  color: #FF3C3C;
font-family: tahoma;
font-size: 12px;
}
 ul.tab li a:hover{
  color:#E60012;
}

 ul.tab li.cur{
  background: #6FB100;
 
}
 ul.tab li.cur a{
   color:#fff;
}
.hd-table{display:none;}

    </style>
    <link rel="stylesheet" type="text/css" href="__STATIC__/hdjs/hdjs.css"/>
    <script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor1_4_3/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor1_4_3/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="__STATIC__/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
    <!--载入uploadify相关文件-->
    <script type="text/javascript" src="__STATIC__/uploadify/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <link href="__STATIC__/uploadify/uploadify.css" type="text/css" rel="stylesheet"></link>

<script type="text/javascript">
    //tab切换
    $(function(){

  $('.tab li ').mouseover(function(){
   var c=$(this).index();
    $(this).addClass('cur').siblings('li').removeClass('cur');
   $('.hd-table').eq(c).show().siblings('.hd-table').hide();


  })

})
</script>
    <!-- 克隆 -->
    <script type="text/javascript">
          $(function(){
                //点击增加
                $('.add').live('click',function(){
                    
                    //克隆一个tr
                    var tr = $(this).parents('tr').clone();
                    $('#spec').append(tr);
                    
                })
                
                //live给未来元素绑定事件
                $('.remove').live('click',function(){
                    if($('tr').length > 2){
                        $(this).parents('tr').remove();
                    }
                    
                })
            })
            
        </script>
            <!-- 异步调取规格和属性 -->
  <script type="text/javascript">
$(function(){
 $('select[name=cat_id]').change(function(){
   // 获得选中的option中的type_id
     var type_id=$(':selected').attr('type_id');
    $.ajax({
    type:"post",
   url:"{|U:'Goods/getAttrSpec'}",
    data:{type_id:type_id},
    dataType:'json',
        success:function(phpData){
                        //属性
                        var attr = '';
                        //规格
                        var spec = '';
                        $.each(phpData, function(k,v) {    
                            //如果是属性(不可选)    
                            if(v.class == 0){
                                attr + = '<tr><td>'+v.attr_name+'</td><td><select name="attr_id[]"><option value="0">请选择</option>';
                                $.each(v.attr_value, function(kk,vv) {    
                                    attr += '<option value="'+vv+'">' + vv + '</option>';                                                          
                                });
                                attr += '</select></td></tr>';
                            }else{
                                spec += '<tr><td>'+v.attr_name+'</td><td><select><option>请选择</option>';
                                $.each(v.attr_value, function(kk,vv) {    
                                    spec += '<option>' + vv + '</option>';                                                          
                                });
                                spec += '</select></td><td><a class="add hd-btn hd-btn-success" href="javascript:;">添加规格</a><a class="remove hd-btn hd-btn-success" href="javascript:;">删除规格</a></td></tr>';
                            }
                        });
                       
                        $('#attr').html(attr);
                        $('#spec').html(spec);
                        
                    }

    });
 
 });


})

  </script>


</head>
<body>
<div class="wrap">
    <div class="hd-title-header">添加商品</div>
    <ul class="tab">
            <li class="cur" ><a href="javascript:;" >基本信息</a></li>
            <li><a href="javascript:;">商品详情</a></li>
            <li><a href="javascript:;">商品属性</a></li>
             <li><a href="javascript:;">商品图集</a></li>
           
    </ul>
    <form action="" method="post" class="form-inline hd-form" enctype="multipart/form-data">
        <table class="hd-table hd-table-list" style="display:block;">
        <thead>
                    <tr>
                        <th colspan="2" class="btn btn-primary">基本信息</th>
                    </tr>
                </thead>
            <tr>
                <th class="w100">商品名称</th>
                <td class="w100">
                    <input type="text" name="goods_name" class="w200"/> 
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">商品货号</th>
                <td class="w100">
                    <input type="text" name="goods_sn" class="w200"/> 
                </td>
                <td></td>
            </tr>

           
             <!-- 获取商品类型 -->

             <tr>
                <th class="w100">商品类型</th>
                <td>
                    <select name="type_id" class="w200">
                     <option value="0">请选择商品类型</option>
                    <foreach from="$type" key="$k" value="$v">
            
                        <option value="{$v.type_id}" >{$v.type_name}</option>

                     </foreach> 
                    </select>
                </td>
               
            </tr>

            <!-- 获取商品品牌 -->
            <tr>
                <th class="w100">商品品牌</th>
                <td>
                    <select name="brand_id" class="w200">
                     <option value="0">请选择商品品牌</option>
                    <foreach from="$brand" key="$k" value="$v">
            
                        <option value="{$v.brand_id}" >{$v.brand_name}</option>

                     </foreach> 
                    </select>
                </td>
               
            </tr>

            <tr>
                <th class="w100">本店价</th>
                <td class="w100">
                    <input type="text" name="shop_price" class="w200"/> 
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">市场价</th>
                <td class="w100">
                    <input type="text" name="market_price" class="w200"/> 
                </td>
                <td></td>
            </tr>
             <tr>
                <th class="w100">促销价</th>
                <td class="w100">
                    <input type="text" name="promote_price" class="w200"/> 
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">库存</th>
                <td class="w100">
                    <input type="text" name="goods_number" class="w200"/> 
                </td>
                <td></td>
            </tr>
             <tr>
                <th class="w100">点击量</th>
                <td class="w100">
                    <input type="text" name="click" class="w200"/> 
                </td>
                <td></td>
            </tr>
             <!-- <tr>
                <th class="w100">商品图片</th>
                <td>
                    <input type="file" name="goods_img" id="" /> 
                </td>
                <td></td>
            </tr> -->
            <tr>
                <th class="w100">缩略图</th>
                <td>
					<input type="file" name="goods_thumb" id="" /> 
                </td>
                <td></td>
            </tr>
            <tr>
                <th class="w100">加入推荐</th>
                <td>
                	<label class="checkbox-inline">
						精品
						<input type="checkbox" value="1" name="is_best" class="check_input">
					</label>
					<label class="checkbox-inline">
						新品
						<input type="checkbox" value="1" name="is_new" class="check_input">
					</label>
					<label class="checkbox-inline">
						热销
						<input type="checkbox" value="1" name="is_hot" class="check_input">
					</label>
					
                </td>
                <td></td>
            </tr>
           </table>
            <table class="hd-table hd-table-list">
             <tr>
                        <th colspan="2" class="btn btn-primary">商品详情</th>
                    </tr>
             <tr>
                <th class="w100">商品描述</th>
                <td>
                    <textarea name="goods_brief" id="" cols="30" rows="10"></textarea>
                </td>
                <td></td>
            </tr>
             <tr>
                <th class="w100">商品详情</th>
                <td>
                 <script id="ed" type="text/plain" style="width:800px;height:400px;" name="goods_desc"></script>
                    <script>
                        var ue = UE.getEditor('ed');
                    </script>  
                </td>
                <td></td>
            </tr>
        
        </table>
       <table class="hd-table hd-table-list">
             <tr>
                        <th colspan="2" class="btn btn-primary">商品属性</th>
            </tr>
             <!--  获取商品分类 -->
            <tr>
                <th class="w100">商品分类</th>
                <td>
                    <select name="cat_id" class="w200">
                        <option value="0">请选择分类</option>
                        <foreach from="$cateData" key="$k" value="$v">
                        <option value="{$v.cid}" type_id="{$v.type_id}">{$v._name}</option>
                       
                        </foreach>
                    </select>
                </td>
                <td></td>
            </tr>
            <p class="hd-title-header">商品属性</p>
            <table class=" hd-table-form" id='attr'>
                  <p class="hd-title-header">商品规格</p>
            </table>
            <table class=" hd-table-form" id='spec'>
                
            </table>
            </table>
          

           <table class="hd-table hd-table-list">
             <tr>
                        <th colspan="2" class="btn btn-primary">商品图集</th>
                    </tr>

            </table>
        <div class="position-bottom">
            <input type="submit" class="hd-btn hd-btn-success" value="添加"/>
        </div>
    </form>
</div>
</body>
</html>